/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Dao;

import entidadesDoBanco.Funcao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author User
 */
public class FuncaoDaoImp implements FuncaoDao{
    
    @Override
    public Object salvar(Object obj) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void alterar(Object obj) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void excluir(int id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Object procurar(Integer id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List listar() throws Exception {

        Connection conn = null;
        PreparedStatement psmt = null;
        ResultSet rs = null;
        List funcoes = new ArrayList();
        Funcao funcao = null;

        try {
            conn = FabricaConexao.abreConexao();
            String BANCO = "SELECT * FROM funcao";
            psmt = conn.prepareStatement(BANCO);
            rs = psmt.executeQuery();
            while ((rs.next())) {
                funcao = new Funcao();
                funcao.setId(rs.getInt("id"));
                funcao.setNome(rs.getString("nome"));
                funcao.setDescricao(rs.getString("descricao"));
                funcoes.add(funcao);
            }
        } catch (Exception e) {
        } finally {
            FabricaConexao.fechaConexao(conn, psmt, rs);
        }
        return funcoes;
    }
}
